<template>
  <component is="a-modal" v-model:visible="visible" :width="1200" :title="title" :mask-closable="false"
    :ok-loading="loading" @cancel="close" @before-ok="submit" >
    <div style="height: 70vh;overflow-y: scroll;">
      <sa-table ref="crudRef" :options="options" :columns="columns" :searchForm="searchForm"  @resetSearch="resetSearch"></sa-table>
    </div>
     
   


  </component>
</template>

<script setup>
import { ref, reactive, computed, watch, onBeforeUnmount, onMounted } from "vue";
import { Message } from "@arco-design/web-vue";
import AsApi from '@/api/system/afterSale'
import { throttle } from "lodash";
import SaTable from '@cps/sa-table/index.vue'
import tool from '@/utils/tool'
import ENUMS from '@/utils/enums'
const emit = defineEmits(["success"]);
const visible = ref(false);
const loading = ref(false);
const crudRef = ref()
const spinLoading = ref(false)
let title = computed(() => {
  return "日志"
});
const searchForm = ref({id:''})  
const columns = reactive([
  { title: 'ID', dataIndex: 'id', width: 200 },
  { title: '发货单号', dataIndex: 'delivery_sn', width: 200 },
  { title: '状态', dataIndex: 'state_text', width: 200 },
  { title: '失败原因', dataIndex: 'fail_msg', width: 120 },
  { title: '时间', dataIndex: 'create_time', width: 180 },
])
const options = reactive({
    api: AsApi.delivery_log_list,//表格数据接口
    operationColumnWidth: 120,//操作欄
    showSearch:false,
    columnAlign: 'center',
    operationColumn:false,
    pageSimple: true,//是否展示操作欄有 以及工具欄
    isTreeTable:false,
    showLine:false,
    add: {//頂部新增按鈕
      show: false,
      auth: ['/core/menu/save'],
      func: async () => {
        editRef.value?.open()
      },
    },
    edit: {//操作欄编辑按鈕
      show: false,
      auth: ['/core/menu/update'],
      func: async (record) => {
        editRef.value?.open('edit',record)
        editRef.value?.setFormData(record)
      },
    },
    isExpand: false,//展開所有子樹
  })
const refresh = async () => {
    crudRef.value?.refresh()
  }

// 打开弹框
const open = async (data) => {
   searchForm.value.id = data.id
  visible.value = true
  spinLoading.value = true
  refresh()
}
const close = () => {
  visible.value = false
};
defineExpose({ open });
</script>